Shader "Hidden/BWDiffuse"
//用于处理图像的灰度转换

{
    Properties
	{
		_MainTex ("Texture", 2D) = "white" {}
		_DisplaceTex ("_DisplaceTexMap", 2D) = "bump" {} //bump 是一个特殊的纹理，它的每个像素都代表一个方向向量
       
	}
	SubShader
{
    Pass
    {
        CGPROGRAM
        #pragma vertex vert_img
        #pragma fragment frag
        #include "UnityCG.cginc"

        sampler2D _MainTex;
        sampler2D _DisplaceTex;

        fixed4 frag (v2f_img i) : SV_Target
        {
            half2 n = tex2D(_DisplaceTex, i.uv);
            half2 d = n*2-1; // 从颜色值转为单位向量
            i.uv += d;
            i.uv = saturate(i.uv);

            float4 c = tex2D(_MainTex, i.uv);
            return c;
        }
        ENDCG
    }
}
}